package com.sos.activity;


import com.sos.Constants;
import com.sos.R;
import com.sos.view.SysContactorListView;
import com.sos.vo.Contactor;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;


/**
 * 通过通讯录导入界面
 * **/
public class AddByContactorActivity extends Activity{
	private final String TAG = AddByContactorActivity.class.getSimpleName();
	
	private SysContactorListView contactorList;
	private TextView btnCancel;
	private int type;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
    	Log.i(TAG, "onCreate");
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(
				WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
                WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
		setContentView(R.layout.add_by_contactor);		

		Intent intent = getIntent();
		type = intent.getIntExtra("TYPE", Constants.TYPE_BLOCKED);
		Log.d(TAG, "type:" + type);
		
		contactorList = (SysContactorListView)findViewById(R.id.contactorList);
		btnCancel = (TextView)findViewById(R.id.btnCancel);
		
		contactorList.setParent(this);
		btnCancel.setOnClickListener(new OnClickListener(){
			@Override
			public void onClick(View v) {
				
				finish();
			}
		});	
	}
	
	public void doSelect(Contactor bean){
		

		Intent intent = new Intent();
		intent.putExtra("name", bean.getName());
		intent.putExtra("phone", bean.getPhone());
		intent.putExtra("TYPE", type);
		AddByContactorActivity.this.setResult(RESULT_OK, intent);
		
		finish();
	}
}
